//
//  GameState.cpp
//  Monster_Martial_Arts_Version_0
//
//  Created by bk on 13/1/5.
//  Copyright (c) 2013年 __MyCompanyName__. All rights reserved.
//

//#include <iostream>
#include "GameState.h"


BaseFiniteStateMachine::BaseFiniteStateMachine()
{
    m_CurrentStateID = INVALID_STATE_ID;
    m_NextCurrentStateID = INVALID_STATE_ID;
    m_PreCurrentStateID = INVALID_STATE_ID;
}

void BaseFiniteStateMachine::AddState(int StatID , IBaseState* ptr)
{
    if (m_mapState.count(StatID) == 0) 
    {
        m_mapState[StatID] = ptr;
    }
}

void BaseFiniteStateMachine::RemoveAll()
{
    
    map<int,IBaseState*>::iterator pi = m_mapState.begin();
    
    while (pi != m_mapState.end()) 
    {
        delete pi->second;    
        
        pi->second = NULL;
        
        pi++;
    }
    
    
    m_mapState.clear();
}

void BaseFiniteStateMachine::SetInitialState(int stateID)
{
    m_CurrentStateID = stateID;
}
